#include <bits/stdc++.h>
using namespace std;
const int N = 3005;

int n, cnt = 0, sum = 0;
int main() {
    cin >> n;
    for (int i = 1, tmp1, tmp2; i <= n; ++i) {
        cin >> tmp1 >> tmp2;
        cnt += tmp1 + tmp2 - 8;
        sum += cnt;
    }
    cout << sum;
    return 0;
}